"""
@author: xxw
@file: 爬取pyqury.py.py
@time: 2023/5/5 16:33
"""

# http://neb-china.com/pshow.asp?id=2765

# pyquery  解析网站页面，爬取内容
import time

import requests
from pyquery import PyQuery as pq

# 获取页面内容
# 重试机会
def load_data(url):
    for i in range(3):
        try:
            res = requests.get(url)
            if res.status_code == 200:
                res.encoding = "utf-8"
                return res.text
            else:
                time.sleep(1)
        except:
            time.sleep(1)

html = load_data("http://neb-china.com/pshow.asp?id=2765")
html_pq = pq(html)
product_name = html_pq(".nbxfh").text().split()[0]
print(product_name)

product_info = html_pq("#zdss").text()
print(product_info)